package StudyCode.summary.mycollection;

import java.util.Enumeration;
import java.util.Iterator;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class EnumerationAsIterable {
	public static <T> Iterable<T> enumerationAsIterable(
			final Enumeration<T> e) {
		return new Iterable<T>() {
			public Iterator<T> iterator() {
				return new Iterator<T>() {
					public boolean hasNext() {
						return e.hasMoreElements();
					}

					public T next() {
						return e.nextElement();
					}

					public void remove() {
						throw new UnsupportedOperationException();
					}
				};
			}
		};
	}
}
